<template>
  <div class="project-detail" v-loading="loading">
    <div class="page-header">
      <div class="header-left">
        <el-button @click="goBack" text>
          <el-icon><ArrowLeft /></el-icon>
          返回
        </el-button>
        <div class="project-info">
          <h1>{{ project?.name }}</h1>
          <div class="project-badges">
            <el-tag :type="getStatusType(project?.status)" size="large">
              {{ project?.status }}
            </el-tag>
            <el-tag
              :type="getPriorityType(project?.priority)"
              size="large"
              effect="plain"
            >
              {{ getPriorityText(project?.priority) }}
            </el-tag>
          </div>
        </div>
      </div>
      <div class="header-right">
        <el-button @click="editProject">
          <el-icon><Edit /></el-icon>
          编辑项目
        </el-button>
        <el-dropdown @command="handleCommand">
          <el-button>
            更多操作
            <el-icon class="el-icon--right"><ArrowDown /></el-icon>
          </el-button>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item command="archive">
                <el-icon><Box /></el-icon>
                归档项目
              </el-dropdown-item>
              <el-dropdown-item command="export">
                <el-icon><Download /></el-icon>
                导出数据
              </el-dropdown-item>
              <el-dropdown-item command="delete" divided>
                <el-icon><Delete /></el-icon>
                删除项目
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
    
    <!-- 项目概览 -->
    <div class="overview-section">
      <div class="overview-cards">
        <div class="overview-card">
          <div class="card-icon progress">
            <el-icon><TrendCharts /></el-icon>
          </div>
          <div class="card-content">
            <h3>{{ project?.progress }}%</h3>
            <p>项目进度</p>
            <el-progress
              :percentage="project?.progress || 0"
              :stroke-width="4"
              :show-text="false"
            />
          </div>
        </div>
        
        <div class="overview-card">
          <div class="card-icon tasks">
            <el-icon><List /></el-icon>
          </div>
          <div class="card-content">
            <h3>{{ project?.taskCount || 0 }}</h3>
            <p>总任务数</p>
            <div class="sub-stats">
              <span>已完成: {{ project?.completedTasks || 0 }}</span>
            </div>
          </div>
        </div>
        
        <div class="overview-card">
          <div class="card-icon members">
            <el-icon><User /></el-icon>
          </div>
          <div class="card-content">
            <h3>{{ project?.memberCount || 0 }}</h3>
            <p>团队成员</p>
            <div class="sub-stats">
              <span>活跃: {{ project?.activeMembers || 0 }}</span>
            </div>
          </div>
        </div>
        
        <div class="overview-card">
          <div class="card-icon issues">
            <el-icon><Warning /></el-icon>
          </div>
          <div class="card-content">
            <h3>{{ project?.issueCount || 0 }}</h3>
            <p>问题数量</p>
            <div class="sub-stats">
              <span>未解决: {{ project?.openIssues || 0 }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <!-- 主要内容区域 -->
    <div class="content-section">
      <div class="content-left">
        <!-- 项目描述 -->
        <div class="info-card">
          <h3>项目描述</h3>
          <p>{{ project?.description || '暂无描述' }}</p>
        </div>
        
        <!-- 项目时间线 -->
        <div class="info-card">
          <h3>项目时间线</h3>
          <div class="timeline-info">
            <div class="timeline-item">
              <span class="timeline-label">开始时间:</span>
              <span class="timeline-value">{{ formatDate(project?.startDate) }}</span>
            </div>
            <div class="timeline-item">
              <span class="timeline-label">结束时间:</span>
              <span class="timeline-value">{{ formatDate(project?.endDate) }}</span>
            </div>
            <div class="timeline-item">
              <span class="timeline-label">持续时间:</span>
              <span class="timeline-value">{{ getDuration() }}</span>
            </div>
          </div>
        </div>
        
        <!-- 最近活动 -->
        <div class="info-card">
          <div class="card-header">
            <h3>最近活动</h3>
            <el-link type="primary" @click="viewAllActivities">查看全部</el-link>
          </div>
          <div class="activity-list">
            <div class="activity-item" v-for="activity in recentActivities" :key="activity.id">
              <div class="activity-icon">
                <el-icon><component :is="getActivityIcon(activity.type)" /></el-icon>
              </div>
              <div class="activity-content">
                <p class="activity-text">{{ activity.description }}</p>
                <span class="activity-time">{{ formatTime(activity.createdAt) }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      
      <div class="content-right">
        <!-- 项目成员 -->
        <div class="info-card">
          <div class="card-header">
            <h3>项目成员</h3>
            <el-button size="small" @click="manageMembers">
              <el-icon><Plus /></el-icon>
              添加成员
            </el-button>
          </div>
          <div class="member-list">
            <div class="member-item" v-for="member in projectMembers" :key="member.id">
              <el-avatar :size="32" :src="member.avatar">
                {{ member.username.charAt(0).toUpperCase() }}
              </el-avatar>
              <div class="member-info">
                <p class="member-name">{{ member.username }}</p>
                <span class="member-role">{{ member.role }}</span>
              </div>
              <el-dropdown @command="handleMemberCommand">
                <el-button text size="small">
                  <el-icon><MoreFilled /></el-icon>
                </el-button>
                <template #dropdown>
                  <el-dropdown-menu>
                    <el-dropdown-item :command="{ action: 'view', id: member.id }">
                      查看详情
                    </el-dropdown-item>
                    <el-dropdown-item :command="{ action: 'remove', id: member.id }" divided>
                      移除成员
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </template>
              </el-dropdown>
            </div>
          </div>
        </div>
        
        <!-- 项目统计 -->
        <div class="info-card">
          <h3>项目统计</h3>
          <div class="stats-chart">
            <div ref="statsChart" class="chart"></div>
          </div>
        </div>
        
        <!-- 快速操作 -->
        <div class="info-card">
          <h3>快速操作</h3>
          <div class="quick-actions">
            <el-button type="primary" @click="createTask">
              <el-icon><Plus /></el-icon>
              创建任务
            </el-button>
            <el-button type="warning" @click="reportIssue">
              <el-icon><Warning /></el-icon>
              报告问题
            </el-button>
            <el-button type="info" @click="viewReports">
              <el-icon><Document /></el-icon>
              查看日报
            </el-button>
          </div>
        </div>
      </div>
    </div>
  </div>

  <!-- 成员管理对话框 -->
  <el-dialog
    v-model="memberDialogVisible"
    title="添加项目成员"
    width="500px"
    :before-close="() => { memberDialogVisible = false; selectedUserId = ''; selectedUserRole = '开发者' }"
  >
    <el-form :model="{ userId: selectedUserId, role: selectedUserRole }" label-width="80px">
      <el-form-item label="选择用户">
        <el-select v-model="selectedUserId" placeholder="请选择用户" style="width: 100%">
          <el-option
            v-for="user in availableUsers"
            :key="user.id"
            :label="`${user.username} (${user.department})`"
            :value="user.id.toString()"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="角色">
        <el-select v-model="selectedUserRole" placeholder="请选择角色" style="width: 100%">
          <el-option label="项目经理" value="项目经理" />
          <el-option label="开发者" value="开发者" />
          <el-option label="测试工程师" value="测试工程师" />
          <el-option label="UI设计师" value="UI设计师" />
          <el-option label="产品经理" value="产品经理" />
        </el-select>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="memberDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="addMember">确定</el-button>
      </div>
    </template>
  </el-dialog>

  <!-- 用户详情对话框 -->
  <el-dialog
    v-model="userDetailDialogVisible"
    title="成员详情"
    width="600px"
  >
    <div class="user-detail" v-if="selectedUserDetail">
      <div class="detail-header">
        <el-avatar :size="60" :src="selectedUserDetail.avatar">
          {{ selectedUserDetail.username.charAt(0).toUpperCase() }}
        </el-avatar>
        <div class="detail-info">
          <h3>{{ selectedUserDetail.username }}</h3>
          <p class="role">{{ selectedUserDetail.role }}</p>
        </div>
      </div>
      <div class="detail-content">
        <div class="detail-item">
          <span class="label">用户名：</span>
          <span class="value">{{ selectedUserDetail.username }}</span>
        </div>
        <div class="detail-item" v-if="selectedUserDetail.email">
          <span class="label">邮箱：</span>
          <span class="value">{{ selectedUserDetail.email }}</span>
        </div>
        <div class="detail-item">
          <span class="label">项目角色：</span>
          <span class="value">{{ selectedUserDetail.role }}</span>
        </div>
        <div class="detail-item" v-if="selectedUserDetail.joinDate">
          <span class="label">加入时间：</span>
          <span class="value">{{ selectedUserDetail.joinDate }}</span>
        </div>
      </div>
    </div>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="userDetailDialogVisible = false">关闭</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref, onMounted, nextTick } from 'vue'
import { useRoute, useRouter } from 'vue-router'

import { ElMessage, ElMessageBox } from 'element-plus'
import * as echarts from 'echarts'
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'

dayjs.extend(relativeTime)
import {
  ArrowLeft,
  Edit,
  ArrowDown,
  Box,
  Download,
  Delete,
  TrendCharts,
  List,
  User,
  Warning,
  Plus,
  MoreFilled,
  Document,

} from '@element-plus/icons-vue'

const route = useRoute()
const router = useRouter()


const loading = ref(false)
const statsChart = ref<HTMLElement>()

// 项目数据
const project = ref({
  id: 1,
  name: '项目管理系统',
  description: '基于Vue 3和Spring Boot的现代化项目管理系统，支持任务管理、问题跟踪、团队协作等功能。',
  status: '进行中',
  priority: 'high',
  progress: 75,
  startDate: new Date('2024-01-01'),
  endDate: new Date('2024-03-31'),
  manager: { username: '张三' },
  taskCount: 25,
  completedTasks: 18,
  memberCount: 8,
  activeMembers: 6,
  issueCount: 3,
  openIssues: 2
})

// 项目成员
const projectMembers = ref([
  {
    id: 1,
    username: '张三',
    role: '项目经理',
    avatar: ''
  },
  {
    id: 2,
    username: '李四',
    role: '前端开发',
    avatar: ''
  },
  {
    id: 3,
    username: '王五',
    role: '后端开发',
    avatar: ''
  },
  {
    id: 4,
    username: '赵六',
    role: 'UI设计师',
    avatar: ''
  }
])

// 最近活动
const recentActivities = ref([
  {
    id: 1,
    type: 'task',
    description: '张三完成了任务：用户认证功能开发',
    createdAt: new Date(Date.now() - 1000 * 60 * 30)
  },
  {
    id: 2,
    type: 'issue',
    description: '李四报告了问题：登录页面样式异常',
    createdAt: new Date(Date.now() - 1000 * 60 * 60 * 2)
  },
  {
    id: 3,
    type: 'member',
    description: '王五加入了项目',
    createdAt: new Date(Date.now() - 1000 * 60 * 60 * 4)
  }
])

// 获取状态类型
const getStatusType = (status?: string): 'success' | 'warning' | 'danger' | 'info' | 'primary' => {
  const types: Record<string, 'success' | 'warning' | 'danger' | 'info' | 'primary'> = {
    '进行中': 'warning',
    '已完成': 'success',
    '已暂停': 'info',
    '已取消': 'danger'
  }
  return types[status || ''] || 'info'
}

// 获取优先级类型
const getPriorityType = (priority?: string): 'success' | 'warning' | 'danger' | 'info' | 'primary' => {
  const types: Record<string, 'success' | 'warning' | 'danger' | 'info' | 'primary'> = {
    'high': 'danger',
    'medium': 'warning',
    'low': 'success'
  }
  return types[priority || ''] || 'info'
}

// 获取优先级文本
const getPriorityText = (priority?: string) => {
  const texts: Record<string, string> = {
    'high': '高',
    'medium': '中',
    'low': '低'
  }
  return texts[priority || ''] || priority
}

// 格式化日期
const formatDate = (date?: Date) => {
  return date ? dayjs(date).format('YYYY-MM-DD') : '-'
}

// 格式化时间
const formatTime = (date: Date) => {
  return dayjs(date).fromNow()
}

// 获取项目持续时间
const getDuration = () => {
  if (!project.value.startDate || !project.value.endDate) return '-'
  const start = dayjs(project.value.startDate)
  const end = dayjs(project.value.endDate)
  const days = end.diff(start, 'day')
  return `${days} 天`
}

// 获取活动图标
const getActivityIcon = (type: string) => {
  const icons: Record<string, any> = {
    task: List,
    issue: Warning,
    member: User,
    project: Document
  }
  return icons[type] || Document
}

// 初始化统计图表
const initStatsChart = () => {
  nextTick(() => {
    if (statsChart.value) {
      const chart = echarts.init(statsChart.value)
      chart.setOption({
        tooltip: {
          trigger: 'item'
        },
        series: [
          {
            name: '任务状态',
            type: 'pie',
            radius: ['40%', '70%'],
            data: [
              { value: 18, name: '已完成' },
              { value: 5, name: '进行中' },
              { value: 2, name: '待开始' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      })
    }
  })
}

// 返回上一页
const goBack = () => {
  router.go(-1)
}

// 编辑项目
const editProject = () => {
  router.push(`/projects/${route.params.id}/edit`)
}

// 处理更多操作
const handleCommand = async (command: string) => {
  switch (command) {
    case 'archive':
      await archiveProject()
      break
    case 'export':
      await exportProject()
      break
    case 'delete':
      await deleteProject()
      break
  }
}

// 归档项目
const archiveProject = async () => {
  try {
    await ElMessageBox.confirm(
      '确定要归档这个项目吗？归档后项目将变为只读状态。',
      '确认归档',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    ElMessage.success('项目归档成功')
  } catch {
    // 用户取消
  }
}

// 导出项目
const exportProject = async () => {
  try {
    ElMessage.info('正在导出项目数据...')
    
    // 模拟导出过程
    await new Promise(resolve => setTimeout(resolve, 2000))
    
    // 创建导出数据
    const exportData = {
      project: project.value,
      exportTime: new Date().toISOString(),
      tasks: [
        { id: 1, title: '用户登录功能开发', status: '已完成' },
        { id: 2, title: '商品管理模块', status: '进行中' },
        { id: 3, title: 'UI界面优化', status: '待开始' }
      ],
      members: projectMembers.value,
      issues: [
        { id: 1, title: '登录页面样式错乱', status: '待处理' },
        { id: 2, title: '商品搜索功能优化', status: '处理中' }
      ]
    }
    
    // 创建并下载文件
    const blob = new Blob([JSON.stringify(exportData, null, 2)], {
      type: 'application/json'
    })
    const url = URL.createObjectURL(blob)
    const link = document.createElement('a')
    link.href = url
    link.download = `project-${project.value.name}-${new Date().toISOString().split('T')[0]}.json`
    document.body.appendChild(link)
    link.click()
    document.body.removeChild(link)
    URL.revokeObjectURL(url)
    
    ElMessage.success('项目数据导出成功')
  } catch (error) {
    console.error('导出失败:', error)
    ElMessage.error('导出项目数据失败')
  }
}

// 删除项目
const deleteProject = async () => {
  try {
    await ElMessageBox.confirm(
      '确定要删除这个项目吗？删除后无法恢复。',
      '确认删除',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    ElMessage.success('项目删除成功')
    router.push('/projects')
  } catch {
    // 用户取消
  }
}

// 处理成员操作
const handleMemberCommand = (command: { action: string; id: number }) => {
  const { action, id } = command
  
  if (action === 'view') {
    viewUserDetail(id)
  } else if (action === 'remove') {
    removeMember(id)
  }
}

// 移除成员
const removeMember = async (id: number) => {
  try {
    await ElMessageBox.confirm(
      '确定要移除这个成员吗？',
      '确认移除',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    projectMembers.value = projectMembers.value.filter(m => m.id !== id)
    ElMessage.success('成员移除成功')
  } catch {
    // 用户取消
  }
}

// 成员管理对话框
const memberDialogVisible = ref(false)
const availableUsers = ref([
  { id: 5, username: '陈七', email: 'chenqi@example.com', department: '技术部' },
  { id: 6, username: '刘八', email: 'liuba@example.com', department: '产品部' },
  { id: 7, username: '孙九', email: 'sunjiu@example.com', department: '设计部' },
  { id: 8, username: '周十', email: 'zhoushi@example.com', department: '测试部' }
])
const selectedUserId = ref('')
const selectedUserRole = ref('开发者')

// 管理成员
const manageMembers = () => {
  memberDialogVisible.value = true
}

// 添加成员
const addMember = async () => {
  if (!selectedUserId.value) {
    ElMessage.warning('请选择要添加的用户')
    return
  }
  
  const user = availableUsers.value.find(u => u.id === parseInt(selectedUserId.value))
  if (!user) {
    ElMessage.error('用户不存在')
    return
  }
  
  // 检查用户是否已经是项目成员
  if (projectMembers.value.some(m => m.id === user.id)) {
    ElMessage.warning('该用户已经是项目成员')
    return
  }
  
  try {
    // 模拟API调用
    await new Promise(resolve => setTimeout(resolve, 500))
    
    // 添加成员到项目
    projectMembers.value.push({
      id: user.id,
      username: user.username,
      role: selectedUserRole.value,
      avatar: ''
    })
    
    // 更新项目成员数量
    if (project.value) {
      project.value.memberCount = projectMembers.value.length
      project.value.activeMembers = projectMembers.value.length
    }
    
    ElMessage.success('成员添加成功')
    memberDialogVisible.value = false
    selectedUserId.value = ''
    selectedUserRole.value = '开发者'
  } catch (error) {
    console.error('添加成员失败:', error)
    ElMessage.error('添加成员失败')
  }
}

// 用户详情对话框
const userDetailDialogVisible = ref(false)
const selectedUserDetail = ref<{
  id: number
  username: string
  role: string
  avatar: string
  email?: string
  joinDate?: string
} | null>(null)

// 查看用户详情
const viewUserDetail = (userId: number) => {
  const member = projectMembers.value.find(m => m.id === userId)
  if (member) {
    selectedUserDetail.value = {
      id: member.id,
      username: member.username,
      role: member.role,
      avatar: member.avatar,
      email: `${member.username.toLowerCase()}@company.com`,
      joinDate: '2024-01-15'
    }
    userDetailDialogVisible.value = true
  }
}

// 查看所有活动
const viewAllActivities = () => {
  router.push(`/projects/${route.params.id}/activities`)
}

// 快速操作
const createTask = () => {
  router.push(`/tasks/create?projectId=${route.params.id}`)
}

const reportIssue = () => {
  router.push(`/issues/create?projectId=${route.params.id}`)
}

const viewReports = () => {
  router.push(`/reports?projectId=${route.params.id}`)
}

// 加载项目数据
const loadProject = async () => {
  loading.value = true
  try {
    // 模拟API调用延迟
    await new Promise(resolve => setTimeout(resolve, 500))
    
    const projectId = route.params.id as string
    console.log('Loading project with ID:', projectId)
    
    // 模拟项目数据映射
    const mockProjects: Record<string, any> = {
      '1': {
        id: 1,
        name: '电商平台重构',
        description: '对现有电商平台进行全面重构，提升用户体验和系统性能。采用微服务架构，提高系统的可扩展性和维护性。',
        status: 'active',
        progress: 75,
        startDate: '2024-01-15',
        endDate: '2024-06-30',
        manager: '张三',
        totalTasks: 45,
        completedTasks: 34,
        totalMembers: 8,
        totalIssues: 12
      },
      '2': {
        id: 2,
        name: '移动应用开发',
        description: '开发跨平台移动应用，支持iOS和Android系统。集成用户认证、数据同步、推送通知等核心功能。',
        status: 'planning',
        progress: 25,
        startDate: '2024-03-01',
        endDate: '2024-08-15',
        manager: '李四',
        totalTasks: 32,
        completedTasks: 8,
        totalMembers: 6,
        totalIssues: 5
      },
      '3': {
        id: 3,
        name: '数据分析系统',
        description: '构建企业级数据分析平台，提供实时数据处理、可视化报表和智能预测功能。',
        status: 'active',
        progress: 60,
        startDate: '2024-02-10',
        endDate: '2024-07-20',
        manager: '王五',
        totalTasks: 28,
        completedTasks: 17,
        totalMembers: 5,
        totalIssues: 8
      },
      '4': {
        id: 4,
        name: '云服务迁移',
        description: '将现有系统迁移到云平台，优化架构设计，提升系统稳定性和安全性。',
        status: 'completed',
        progress: 100,
        startDate: '2023-10-01',
        endDate: '2024-01-31',
        manager: '赵六',
        totalTasks: 22,
        completedTasks: 22,
        totalMembers: 4,
        totalIssues: 2
      }
    }
    
    // 根据ID获取对应的项目数据
    const projectData = mockProjects[projectId]
    if (projectData) {
      project.value = projectData
    } else {
      // 如果找不到对应项目，使用默认数据
      ElMessage.warning('项目不存在，显示默认数据')
      project.value = mockProjects['1']
    }
    
  } catch (error) {
    console.error('Failed to load project:', error)
    ElMessage.error('加载项目详情失败')
  } finally {
    loading.value = false
  }
}

onMounted(() => {
  loadProject()
  initStatsChart()
})
</script>

<style scoped>
.project-detail {
  padding: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.header-left {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.project-info h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
  color: #333;
}

.project-badges {
  display: flex;
  gap: 8px;
}

.header-right {
  display: flex;
  gap: 12px;
}

.overview-section {
  margin-bottom: 24px;
}

.overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.overview-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 16px;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
}

.card-icon.progress {
  background: #409eff;
}

.card-icon.tasks {
  background: #67c23a;
}

.card-icon.members {
  background: #e6a23c;
}

.card-icon.issues {
  background: #f56c6c;
}

.card-content {
  flex: 1;
}

.card-content h3 {
  margin: 0 0 4px 0;
  font-size: 24px;
  color: #333;
}

.card-content p {
  margin: 0 0 8px 0;
  color: #666;
  font-size: 14px;
}

.sub-stats {
  font-size: 12px;
  color: #999;
}

.content-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.info-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.info-card h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: #333;
}

.info-card p {
  margin: 0;
  color: #666;
  line-height: 1.6;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h3 {
  margin: 0;
}

.timeline-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timeline-label {
  color: #666;
  font-size: 14px;
}

.timeline-value {
  color: #333;
  font-weight: 500;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
}

.activity-text {
  margin: 0 0 4px 0;
  font-size: 14px;
  color: #333;
}

.activity-time {
  font-size: 12px;
  color: #999;
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.member-info {
  flex: 1;
}

.member-name {
  margin: 0 0 4px 0;
  font-size: 14px;
  color: #333;
}

.member-role {
  font-size: 12px;
  color: #666;
}

.chart {
  height: 200px;
}

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
  }
  
  .header-left {
    flex-direction: column;
    gap: 12px;
  }
  
  .overview-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .content-section {
    grid-template-columns: 1fr;
  }
  
  .overview-card {
    flex-direction: column;
    text-align: center;
  }
}

/* 用户详情对话框样式 */
.user-detail {
  .detail-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ebeef5;
    
    .detail-info {
      margin-left: 15px;
      
      h3 {
        margin: 0 0 5px 0;
        font-size: 18px;
        font-weight: 600;
        color: #303133;
      }
      
      .role {
        margin: 0;
        color: #909399;
        font-size: 14px;
      }
    }
  }
  
  .detail-content {
    .detail-item {
      display: flex;
      margin-bottom: 12px;
      
      .label {
        width: 80px;
        color: #606266;
        font-weight: 500;
        flex-shrink: 0;
      }
      
      .value {
        color: #303133;
        flex: 1;
      }
    }
  }
}

.dialog-footer {
  text-align: right;
}
</style>